NULL =

SUBDIRS=po
if BUILD_DOCUMENTATION
SUBDIRS += man
endif

INCLUDES =					\
	-I$(top_srcdir)				\
	-I$(top_builddir)			\
	-DXDGCONFDIR=\"$(sysconfdir)/xdg\"	\
	-DLOCALEDIR=\"$(datadir)/locale\" 	\
	-DSTANDALONE_XDG_USER_DIR_LOOKUP	\
	$(NULL)

EXTRA_DIST= config.rpath translate.c autogen.sh \
	user-dirs.conf user-dirs.defaults xdg-user-dir xdg-user-dirs.desktop

xdgdir=$(sysconfdir)/xdg
xdg_DATA=user-dirs.conf user-dirs.defaults

xdgautostartdir=$(xdgdir)/autostart
xdgautostart_DATA = xdg-user-dirs.desktop

libraries = $(LIBINTL)

bin_PROGRAMS =					\
	xdg-user-dirs-update			\
	$(NULL)

bin_SCRIPTS =					\
	xdg-user-dir				\
	$(NULL)

xdg_user_dirs_update_SOURCES = xdg-user-dirs-update.c
xdg_user_dirs_update_LDADD = $(libraries)


noinst_PROGRAMS= \
	xdg-user-dir-lookup

xdg_user_dir_lookup_SOURCES = \
	xdg-user-dir-lookup.c

dist-hook: check-translations
	@if test -d "$(srcdir)/.git"; \
	then \
		echo Creating ChangeLog && \
		( cd "$(top_srcdir)" && \
			echo '# Generated by Makefile. Do not edit.'; echo; \
			$(top_srcdir)/missing --run git log --stat ) > ChangeLog.tmp \
		&& mv -f ChangeLog.tmp $(top_distdir)/ChangeLog \
		|| ( rm -f ChangeLog.tmp ; \
			echo Failed to generate ChangeLog >&2 ); \
	else \
		echo A git clone is required to generate a ChangeLog >&2; \
	fi

check-translations:
	@for i in $(top_srcdir)/po/*.po ; do								\
		if ! grep -q `basename $$i | sed 's,.po,,'` $(top_srcdir)/po/LINGUAS ; then		\
			echo '***' `basename $$i | sed 's,.po,,'` missing from po/LINGUAS '***' ;	\
			exit 1;										\
		fi;											\
	done;

